#!/usr/bin/python
# -*- coding: utf-8 -*-

from pylot.data.regexpr import cmake_doc_header
from pylot.tools.path import Path

filepath = Path('install/tools/cmake_doc.txt').abspath()
openfile = open(filepath, 'r')

filepath = Path('install/cmake_options-all.csv').abspath()
outfile = open(filepath, 'w')

line = openfile.readline()
while line :
  line = openfile.readline()
  if cmake_doc_header.match(line.strip()) :
    line = line.strip()
    try :
      name, tooltip = line.split(':')
      print >> outfile, '%s;;;;;%s;cmake_expert;%s (%s)' %(name, tooltip.strip(), name.capitalize().replace('_', ' '), name)
    except ValueError :
      pass

outfile.close()
openfile.close()